<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@include file="/pageRc/common/common.jsp"%>

<!DOCTYPE html>
<html lang="en" style="overflow-x: hidden">
<head>
<meta charset="UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport"
	content="initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
<meta name="format-detection" content="telephone=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="msapplication-tap-highlight" content="no">

<link rel="stylesheet"
	href="<%=commonPath %>/pageRc/layui/css/layui.css" media="all">
<script type="text/javascript"
	src="<%=commonPath %>/pageRc/js/jquery-1.9.1.min.js"></script> 
<script type="text/javascript"
	src="<%=commonPath %>/pageRc/common/utils.js"></script>
<script type="text/javascript"
	src="<%=commonPath %>/pageRc/common/msgTool.js"></script>
<script type="text/javascript"
	src="<%=commonPath %>/pageRc/layui/layui.js"></script>

<title>奖金表数据导入</title>
<style>
.Wdate {
    border: #efefef 1px solid;
    height: 38px;
    background: #ffffff url(datePicker.gif) no-repeat right;
}
</style>
<script>

	//注意：选项卡 依赖 element 模块，否则无法进行功能性操作
	layui.use('element', function() {
		var element = layui.element();

		//…
	});
</script>
<jsp:include page="publicMethod.jsp"/>
</head>
<body class="layui-main">
<blockquote class="layui-elem-quote">
    奖金表数据导入
</blockquote>
     <form class="layui-form layui-form-pane" id="uploadExcelForm" action="" method="post" enctype="multipart/form-data" >
	        <div class="layui-form-item ">
	         <div class="layui-inline">
	                <input id="excelFile" type="file" name="excelFile" lay-type="file"  " class="layui-upload-file" >
	        </div>
	       </div>
     </form>
            
<!-- 数据列表 -->
	
    <form id="createForm" name="createForm" class="layui-form"
          action="">
        <div class="layui-form-item">
				<div class="layui-inline">
					<div class="layui-inline">
					<select name="proGroupNo" id="proGroupNo"
						lay-filter="proGroupSelect" style="width: 210;">
						<c:forEach items="${groupList}" var="group">
						
							<option value="${group.proGroupNo}">${group.proGroupName}</option>
						</c:forEach>
					</select>
				</div>
				<div class="layui-inline">
					<select name="proTeamNo" id="proTeamNo" style="width: 210;">
						<option value="">项目组名称</option>
						<option value="">全部</option>
						<c:forEach items="${teanList}" var="tean">
							<option value="${tean.proTeamNo}">${tean.proTeamName}</option>
						</c:forEach>
					</select>
				</div>
					<div class="layui-inline">
						<input class="layui-input"  id="needNo"
							placeholder="项目编号">
					</div>
            
       
                   <div class="layui-inline">
                    <button class="layui-btn" type="button" data-method="doSearchSum" id='doSearchSum'>查询</button>
                  </div>
          </div>
        </div>
        <div class="layui-form-item" id="dateDiv">
            <div class="layui-inline">
                <table class="layui-table" lay-even="" lay-skin="line" style="text-align: center;">
                    <colgroup>
                        <col width="140">
                        <col width="140">
                        <col width="140">
                        <col width="140">
                        <col width="140">
                        <col width="140">
                        <col width="240">
                    </colgroup>
                    <thead>
                    <tr>
                        <th style="text-align: center">团队名称</th>
                        <th style="text-align: center">项目组</th>
                        <th style="text-align: center">需求编号</th>
                        <th style="text-align: center">产品编号</th>
                        <th style="text-align: center">项目金额</th>
                        <th style="text-align: center">系统销售金额</th>
                        <th style="text-align: center">合同回款金额</th>
                        <th style="text-align: center">项目费用</th>
                        <th style="text-align: center">操作</th>
                    </tr>
                    </thead>
                    <tbody id="detailDiv">
                    </tbody>
                    <script id="tplSrc" type="text/html">
                        {{#  layui.each(d.rsList, function(index, x){}}
                        <tr>
                            <td>{{x.proGroupName==undefined?'':x.proGroupName}}</td>
                            <td>{{x.proTeamName==undefined?'':x.proTeamName}}</td>
                            <td>{{x.needNo==undefined?'':x.needNo}}</td>
                            <td>{{x.contractNo==undefined?'':x.contractNo}}</td>
                            <td>{{x.needMoney==undefined?'':x.needMoney}}</td>
 							<td>{{x.xthdje==undefined?'':x.xthdje}}</td>
                            <td>{{x.paybackAmount==undefined?'':x.paybackAmount}}</td>
                            <td>{{x.projectFee==undefined?'':x.projectFee}}</td>
                            <td>
                                <button class="layui-btn" type="button" onclick="deleteProCost('{{x.needNo}}','{{x.proTeamName}}')">删除</button>
                            </td>
                        </tr>
                        {{#  }); }}
                    </script>
                </table>
            </div>
        </div>
			<div class="layui-form-item">
				<div class="layui-inline">
					<div id="laypageDiv"></div>
				</div> 
		 </form>
	
		<input id="totalNum" type="hidden" name="totalNum" >
</body>
<script type="text/javascript">
var path="<%=commonPath%>";
var msg =new msgTool();
layui.use(
		[ 'form', 'layer', 'laytpl', 'laypage','laydate','upload' ],
		function() {
			var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句
	        var form = layui.form()
	            ,layer = layui.layer
	            ,laypage = layui.laypage
	            ,laytpl = layui.laytpl
	        	,upload = layui.upload;
			
	         upload({
	            url :path+ '/page/main/updNeedInfo.do',
	            ext : 'xls|xlsx',
	            title : '请选择准备好的Excel文件',
	            before : function(input) {
	                // 返回的参数item，即为当前的input DOM对象
	                console.log('文件上传中');
	            },
	            success : function(res) {
	            	if(res.body=="OK"){
	            		layer.tips('导入数据成功！', '#excelFile', {
	  			   		  tips: [2, '#1d953f'],
	  			   		  area: ['150px', '35px'],
	  			   		  time: 2000
	  			   		});
	    				
	    			}
	            	if(res.body=="FALSE1"){
	            		layer.tips('Excle表格中有数据为空,请检查！', '#excelFile', {
	  			   		  tips: [2, '#FF3030'],
	  			   		  area: ['150px', '50px'],
	  			   		  time: 3000
	  			   		});
	    				
	    			}
	            	if(res.body=="FALSE2"){
	            		layer.tips('Excle表格中月份数据格式不正确,请检查！', '#excelFile', {
	  			   		  tips: [2, '#FF3030'],
	  			   		  area: ['150px', '50px'],
	  			   		  time: 3000
	  			   		});
	    				
	    			}
	            	if(res.body=="FALSE3"){
	            		layer.tips('Excle表格中没有任何数据,请检查！', '#excelFile', {
	  			   		  tips: [2, '#FF3030'],
	  			   		  area: ['150px', '50px'],
	  			   		  time: 3000
	  			   		});
	    				
	    			}
	            	if(res.body=="FALSE4"){
	            		layer.tips('Excle表格中有重复工号！', '#excelFile', {
	  			   		  tips: [2, '#FF3030'],
	  			   		  area: ['150px', '50px'],
	  			   		  time: 3000
	  			   		});
	    				
	    			}
	            	if(res.body=="FALSE5"){
	            		layer.tips('Excle表格中数据和现有数据有重复,请检查！', '#excelFile', {
	  			   		  tips: [2, '#FF3030'],
	  			   		  area: ['150px', '50px'],
	  			   		  time: 3000
	  			   		});
	    				
	    			}
	            	if(res.body=="FALSE6"){
	            		layer.tips('Excle表格和模板格式不匹配,请检查！', '#excelFile', {
	  			   		  tips: [2, '#FF3030'],
	  			   		  area: ['150px', '50px'],
	  			   		  time: 3000
	  			   		});
	    				
	    			}
	            }
	        });

	        //监听特定的自定义事件。你可以把它看作是一个ID选择器
	        form.on('submit(queryData)', function(data) {
	            each();
	            return false;
	        }); 
	        var active = {
	        		
	        		doSearchSum : function() { //搜索
			      	    active.doSearchDetail(1); 
			         }
	        		
	            ,doSearchDetail:function(v_curr){ 
	            	if(v_curr==1){	
		      	    var getTpl = tplSrc.innerHTML;
	        	 		var dataObj = {
		  						"startRow" : (v_curr-1)*15,
		  						"pageSize" : 15,
		  						"proGroupNo" : $("#proGroupNo").val(),
		  						"proTeamNo" : $("#proTeamNo").val(),
		  						"needNo" : $("#needNo").val(),
		  						"startDate":$("#startDate").val(),
								"endDate":$("#endDate").val()
		  					
		  					};
	        			msg.sendMsg("/page/main/searchRewardFormInfor.do",dataObj,function(data){
 	          				laytpl(getTpl).render(data.body, function(html){ 
	          					detailDiv.innerHTML = html;
	          					$('#totalNum').val(data.body.count)
	          				});
 	          				totalNum = Math.ceil(data.body.count/15);
 	          				laypage({
				                 cont: 'laypageDiv'
				                 ,pages:totalNum
				                  ,jump: function(obj,first){
				                	  if(first!=true){
				                	  	active.doSearchDetail(obj.curr); 
				                	  }
				                   } 
				                 }); 
 	          			});
	            	 }else{
	            		  var getTpl = tplSrc.innerHTML;
		        	 		var dataObj = {
			  						"startRow" : (v_curr-1)*15,
			  						"pageSize" : 15,
			  						"proGroupNo" : $("#proGroupNo").val(),
			  						"proTeamNo" : $("#proTeamNo").val(),
			  						"needNo" : $("#needNo").val(),
			  						"startDate":$("#startDate").val(),
									"endDate":$("#endDate").val()
			  					
			  					};
		        			msg.sendMsg("/page/main/searchRewardFormInfor.do",dataObj,function(data){
	 	          				laytpl(getTpl).render(data.body, function(html){ 
		          					detailDiv.innerHTML = html;
		          					$('#totalNum').val(data.body.count)
		          				});
	 	          			});
	            	 }
	                 }, 
	                 doExcel:function() {
	                		var dataObj = {};
							msg.sendMsg("/page/main/downProjectCostExcelFile.do",
									dataObj, function(data) {
										window.location.href = path+ "/downFile/"+ data.body.fileName
		});
	                	 //window.location.href = path +"/excleTemplate/projectCostTemplate.xls";
        			   }

	                 }
	        $('#doSearchSum').on('click', function(){
	            var othis = $(this), method = othis.data('method');
	            active[method] ? active[method].call(this, othis) : '';
	          }); 
	        $('.layui-btn').on('click', function(){
	            var othis = $(this), method = othis.data('method');
	            active[method] ? active[method].call(this, othis) : '';
	          }); 
	        
	       
		});
	 
function deleteProCost(needNo,proTeamName) {
    var jsonDate = {};
    jsonDate.needNo = needNo;
    jsonDate.proTeamName = proTeamName;
    layer.confirm("你确定要删除这条信息吗？。",{icon:3,title:"提示"},function(index){
        msg.sendMsg("/page/main/deleteRewardForm.do", jsonDate, function (data) {
        	if(data.body=="FALSE"){
        		layer.alert("删除失败！");
			}
        	if(data.body=="OK"){
        		  flush();
                  layer.alert("删除成功！");
			}
            
        });
    });
}
function flush(){
    $('#doSearchSum').click()
}
</script>
</html>